package com.tuzhi.filestore.mq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 功能说明：
 *
 * @author abu
 * @version 1.1.0
 * @date 2023/2/20
 */
 @Configuration
public class MqConifg {

    @Bean
    public Queue fileStoreQueue(){
        /**
         * name: 队列名称
         * durable 是否持久化
         * exclusive 是否是排他队列 只有创建者可以使用
         * autoDelete 声明此队列为临时队列，最后一个消费者使用完自动删除
         */
        return new Queue(Constant.queueName, true, false, false);
    }
    @Bean
    public TopicExchange msgExchange(){
        return new TopicExchange(Constant.topicExchange, true, false);
    }


    @Bean
    public Binding fileStoreBiding(){
        return BindingBuilder.bind(fileStoreQueue()).to(msgExchange()).with(Constant.routingKey);
    }


}
